use std::error::Error;

pub type ByteResult<T> = Result<T,ByteError>;

#[derive(Debug)]
pub enum ByteError {
    Io(std::io::Error),
    BitRange,
}

impl std::fmt::Display for ByteError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Io(e) => write!(f,"[byte][io]{e}"),
            Self::BitRange => write!(f,"[byte]bit transfer error"),
        }
    }
}

impl Error for ByteError { }

impl From<std::io::Error> for ByteError {
    fn from(value: std::io::Error) -> Self {
        Self::Io(value)
    }
}